#ifndef GEOTIFFMERGER_HXX
#define GEOTIFFMERGER_HXX

#include <opencv/cv.h>
#include <string.h>

class GeoTiffImage;

class GeoTiffMerger
{
public:
    GeoTiffMerger();

	inline void setSourceDirectory(const char* srcDir) { strcpy(_sourceDir, srcDir); }
	inline void setDestFileName(const char* dstName) { strcpy(_destFileName, dstName); }
	inline void setImageScaleFactor(double factor) { _imageScaleFactor = factor; }

	inline char* getSourceDirectory() { return _sourceDir; }
	inline char* getDestFileName() { return _destFileName; }

	void mergeTiffFiles();
private:
	void estimateParameters();
	void mergeFiles();
	void blendImageBlock(IplImage* source, IplImage* target);

	void blendRGBAImage(IplImage* source, IplImage* target);
	void blendGrayImage(IplImage* source, IplImage* target);

	void exportTxtDEM(IplImage* image );

private:
    char _sourceDir[256];
    char _destFileName[256];

	double _minModelCoordX;
	double _maxModelCoordX;
	double _minModelCoordY;
	double _maxModelCoordY;

	double _avgXScale;
	double _avgYScale;

	unsigned int _depth;
	unsigned int _channels;

	double _imageScaleFactor;

	float _maxVal;
	float _minVal;

	GeoTiffImage* _targetImage;
};

#endif // GEOTIFFMERGER_HXX
